<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<title>扫码支付</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta http-equiv="Cache-Control"
	content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<style>
.logo {
  width: 96px;
  height: 30px;
  margin: auto;
  display: block;
  background: url(../resources/img/logo.png) no-repeat top center;
  background-size: 96px 28px;

}
table,th,td {
	border: 1px solid blue;
}
html, body{ margin:0; height:99%; background-color:  #F5F5F5}
</style>
</head>
<body>
		<div style="height: 90%;" >
			<img src="../resources/img/zzzf.gif"	width="100%" height="auto">
			<div id="status" style="text-align: center;"></div>
		</div>
		
	  <div class="weui-footer weui-footer_fixed-bottom" style="text-align: center;">
   
        <p class="weui-footer__text" style="color: #000;margin-top: 5px;">
            <img height="10px" src="../resources/img/logo.png"/>
  		   <div style="width: 100%;text-align: center;color: 	#A9A9A9;font-size: 12px ;font-family: FangSong">北京路盟科技有限公司</div>
        </p>
    </div>
	<script>
	
   // var code = ${code};
 
    var message = '${message}';

    if(code == 200){
        wap_pay();
    }else{
        //document.getElementById("status").innerHTML=" <span class='up' >'+message+'</span>";
        document.getElementById("status").innerHTML=" <span class='up' >请使用微信或者支付宝打开进行扫码支付</span>";
        document.getElementById("payloading").style.display = "none";
    }

    function wap_pay() {

        var charge = ${data.data};

        document.getElementById("amount").innerHTML =  "¥ " +  (charge.amount/100).toFixed(2) ;

        var channel ='alipay_wap';

        var ua = window.navigator.userAgent.toLowerCase();
        //判断是不是微信
        if ( ua.match(/MicroMessenger/i) == 'micromessenger' ) {
            channel ='wx_pub';
        }
        //判断是不是支付宝
        else if (ua.match(/AlipayClient/i) == 'alipayclient') {
            channel ='alipay_wap';
        }else{
            document.getElementById("status").innerHTML=" <span class='up' >请使用微信或者支付宝打开进行扫码支付</span>";
            document.getElementById("payloading").style.display = "none";
            return;
        }

        pingpp.createPayment(charge, function(result, err){

            if (result == "success") {
                //只有微信公众账号 wx_pub 支付成功的结果会在这里返回，其他的支付结果都会跳转到 extra 中对应的 URL。
                window.location.href = "http://www.itc-pay.com/appapi/callBack/qrcodeAlipayFinsh?out_trade_no="+charge.order_no+"&total_amount="+ (charge.amount/100).toFixed(2);
            } else if (result == "fail") {
                // charge 不正确或者微信公众账号支付失败时会在此处返回
                window.location.href = "http://www.itc-pay.com/appapi/callBack/qrcodeAlipayFinsh";


            } else if (result == "cancel") {
                // 微信公众账号支付取消支付
                document.getElementById("status").innerHTML=" <span class='up' >您已取消通行费支付！</span>";
                document.getElementById("payloading").style.display = "none";
            }
        });
    }
   
</script>
</body>
</html>
